/**
 * @description 在途回购信息
 * @author wangjianjun
 */
import React, { PureComponent } from 'react';
import { TableC } from '../../../../comps';
import 'moment/locale/zh-cn';

export default class RepurchaseInfor extends PureComponent {
  constructor(props) {
    super(props);
  }

  //触发回填质押券
  reNewPledgeBond = (record) => {
    this.props.reNewPledgeBond(record.instructionSend);
  };

  render() {
    let { columns, dataSource } = this.props;
    let widths = '5.18%';
    if (this.props.tradeBook == '1') {
      widths = '120px';
    }
    if (columns && columns.length > 0) {
      columns.map((item, key) => {
        if (item.key == 'buyBackCode') {
          item.width = widths;
          item.fixed = 'left';
          item.render = (text, record) => {
            return (
              <span style={{ color: '#4D86FF', cursor: 'pointer ' }} onDoubleClick={() => this.reNewPledgeBond(record)}>
                {text}{' '}
              </span>
            );
          };
        }
        if (item.key == 'transactionTime') {
          item.width = '5.56%';
        }
        if (item.key == 'orderSide') {
          item.width = '5.56%';
        }
        // if (item.key=='buyBackName') {
        //   item.width = '5.56%'
        // }
        if (item.key == 'repoRate') {
          item.type = 'number';
          item.width = '5.56%';
        }

        if (item.key == 'settlementDate') {
          item.width = '5.56%';
        }
        if (item.key == 'firstSettlemenDate') {
          item.width = '5.56%';
        }
        if (item.key == 'repurchaseDays') {
          item.type = 'number';
          item.width = '5.56%';
        }
        if (item.key == 'occupationDays') {
          item.type = 'number';
          item.width = '5.56%';
        }
        if (item.key == 'pledgeBondCode') {
          item.width = '5.46%';
        }

        if (item.key == 'agreecode') {
          item.width = '5.46%';
          // item.type = 'number'
        }

        if (item.key == 'investmentType') {
          item.width = '5.46%';
        }
        if (item.key == 'pledgeBondShortName') {
          item.width = '5.46%';
        }
        if (item.key == 'pledgeAmount') {
          item.width = '6.05%';
          item.type = 'number';
        }
        if (item.key == 'totalFaceValue') {
          item.type = 'money';
          item.width = '5.56%';
        }
        if (item.key == 'conversionRate') {
          item.type = 'number';
          item.width = '5.56%';
        }
        if (item.key == 'expireAmount') {
          // item.align = 'left'
          item.type = 'money';
          item.width = '5.5%';
        }

        if (item.key == 'counterPartyper') {
          item.width = '5.46%';
        }
        if (item.key == 'counterPartyorg') {
          item.width = '6.10%';
        }
      });
      columns = columns.filter(({ key }) => key !== 'buyBackName');
    }

    return (
      <div>
        <TableC noDataHeight="165px"  columns={columns} dataSource={dataSource} hidePage={true} scroll={{ x: 2100, y: 350 }} />
      </div>
    );
  }
}
